function startCa()
{
	var pos = 0, ctx = null, saveCB, image = [];

	var canvas = document.createElement("canvas");
	canvas.setAttribute('width', 320);
	canvas.setAttribute('height', 240);
	
	if (canvas.toDataURL) {


		ctx = canvas.getContext("2d");
		
		image = ctx.getImageData(0, 0, 320, 240);
	
		saveCB = function(data) {
			
			var col = data.split(";");
			var img = image;

			for(var i = 0; i < 320; i++) {
				var tmp = parseInt(col[i]);
				img.data[pos + 0] = (tmp >> 16) & 0xff;
				img.data[pos + 1] = (tmp >> 8) & 0xff;
				img.data[pos + 2] = tmp & 0xff;
				img.data[pos + 3] = 0xff;
				pos+= 4;
			}

			if (pos >= 4 * 320 * 240) {
				ctx.putImageData(img, 0, 0);
				$.post("/Member/savephoto", {type: "data", image: canvas.toDataURL("image/png")},function(data){
				$("#resultImg").attr("src", data);
				$("#MemReg_Avatar").attr("src", data);
				$("#MemReg_Photo").val(data);
				});
				pos = 0;
			}
		};

	} else {

		saveCB = function(data) {
			image.push(data);
			
			pos+= 4 * 320;
			
			if (pos >= 4 * 320 * 240) {
				$.post("/Member/savephoto", {type: "pixel", image: image.join('|')});
				pos = 0;
			}
		};
	}

	$("#webcam").webcam({

		width: 320,
		height: 240,
		mode: "callback",
		swffile: "/App/Tpl/default/Public/swf/jscam_canvas_only.swf",

		onSave: saveCB,

		onCapture: function () {
			webcam.save();
		},

		debug: function (type, string) {
			console.log(type + ": " + string);
		}
	});

}

